package team.star.werespos.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * User class<br/>
 *
 * @author hdonghong
 * @since 2018/04/30
 */
@TableName("`user`")
@Data
@Accessors(chain = true)
public class User implements Serializable {

    private static final long serialVersionUID = 3137252027898189855L;

    @TableId
    private Integer uid;

    private String username;

    @Length(min = 1, max = 16, message = "长度范围必须大于1小于16")
    private String password;

    private String salt;

    @TableField(exist = false)
    private Set<Role> roles;

    public User() {
        roles = new HashSet<>();
    }
}
